package cn.com.connext.scrm.repository.master;


import cn.com.connext.scrm.domain.master.ActivityModuleConfigChild;
import cn.com.connext.scrm.domain.master.IndexModuleConfigChild;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface IndexModuleConfigChildRepository extends JpaRepository<IndexModuleConfigChild, Long>, JpaSpecificationExecutor {
    @Query(value = "select * FROM index_module_config_child where index_module_config_id= :indexModuleConfigId",nativeQuery = true)
    List<IndexModuleConfigChild> findByIndexModuleConfigId(@Param("indexModuleConfigId") Long indexModuleConfigId);

    @Modifying
    @Query(value = "delete FROM index_module_config_child where index_module_config_id= :indexModuleConfigId",nativeQuery = true)
    void deleteByIndexModuleConfigId(@Param("indexModuleConfigId") Long indexModuleConfigId);

    List<IndexModuleConfigChild> indexModuleConfigId(@Param("indexModuleConfigId") Long indexModuleConfigId);
    @Modifying
    @Query(value = "delete from index_module_config_child where  id  not in :list and index_module_config_id= :indexModuleConfigId ", nativeQuery = true)
    void deleteByCondition(@Param("list") List<Long> idList, @Param("indexModuleConfigId") Long indexModuleConfigId);
}
